<?php
require_once "../Common/values.php";
require_once "../Common/database.php";


ini_set('SMTP', $smtp);
ini_set('sendmail_from', 'helpdesk@'.$company.'.com');
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0;' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1;' . "\n";
// Additional headers
$headers .= 'To: ;' . "\n";
$headers .= 'From: '.$title.' <vhs@'.$company.'.com>;' . "";
$Name = $company; //senders name
$email = 'helpdesk@'.$company.'.com'; //senders e-mail adress
$result = mysql_query("SELECT * FROM tbljobs WHERE LogNumber='$_GET[log]'");
$row = mysql_fetch_array($result);
$recipient=$row[mail];

$mail_body1 = '
<center><h1>'.$title.'</h1></center>

<br><h2>The below job has been updated no action is required </h2>
<br><b>Job Number: '.$_GET[log].'</b> http://'.$ip.'/helpdesk/publicview.php?log='.$_GET[log].'"

<p><b>Requestor : </b>'.$row[Requestor].'
<br><b>Subject :</b>   '.$row[Subject].'
<br><b>Problem : </b><p>  '.nl2br($row[Problem]).'
<p><b>Solution :</b>
<p>';
$result = mysql_query("SELECT * FROM tblsolutions WHERE LogNumber='$_GET[log]' ORDER BY `key` DESC");

$mail_body1 .= '<table border=1 Width="100%"><tr><td>Date</td><td>Time</td><td>Operator</td><td>Solution</td><td>Time Spent</TD>';
while($row = mysql_fetch_array($result))
{
$mail_body1 .= '<tr><td>'.$row['Date'].'</td><td>'.$row['Time'].'</td><td>'.$row['Operator'].'</td><td>'.nl2br($row['Solution']).'</td><td>'.$row['TimeS'].'</tr>';
$total=$row[TimeS]+$total;

}

$mail_body1 .='</table> <br> <b>Please ring if you have any questions 1220 or 01752 636350';

$mail_body1 .= '<br><br>see all jobs in progress http://'.$ip.'/VHS/helpdesk/dashboard.php
<br>If you need to get an update on a loged call please check by clicking on the log number above or call 1220 or 01752 636350

<br>Message generated by VHS server on behalf of '.$company.' IT Department please do not reply to this message

<br>Thank you '; //mail body
$subject = 'VHS job updated'; //subject

mail($recipient, $subject, $mail_body1, $headers);

$query="INSERT INTO tblSolutions VALUES ('$_GET[log]','$date','$time','$user','Sent requestor update email','0','')";
mysql_query($query);

echo '<h2>Email sent (update)</h2><br><a href="../index.php?p=hupdate&log='.$_GET[log].'">Back</a>'
?>
